import QtQuick 2.0

Column {
    id: sidebtnmenu
    spacing: 15
    
    property color unselectColor: "#FF666666"
    property color selectColor: "#FF333333"
    
    function unselectAllSideButtons() {
        if(userSelection.visible == false){
            favorites.unselect();
            recipes.unselect();
            appliances.unselect();
            calendar.unselect();
            social.unselect();
            map.unselect();
            music.unselect();
            news.unselect();
            weather.unselect();
            games.unselect();
            sticky.unselect();
            groceries.unselect();
            settings.unselect();
        }
    }

    function selectSideButton(target) {
        if(userSelection.visible == false){
            switch(target) {
                case "favorites":   favorites.select(); break;
                case "recipers":    recipes.select(); break;
                case "appliances":  appliances.select(); break;
                case "calendar":    calendar.select(); break;
                case "social":      social.select(); break;
                case "map":         map.select(); break;
                case "music":       music.select(); break;
                case "news":        news.select(); break;
                case "weather":     weather.select(); break;
                case "games":       games.select(); break;
                case "sticky":      sticky.select(); break;
                case "groceries":   groceries.select(); break;
                case "settings":    settings.select(); break;
            }
        }
    }

    function setVisible(object) {
        if(userSelection.visible == false){
            webpage.visible = false;
            socialContent.visible = false;
            gameContent.visible = false;
            mapContent.visible = false;
            stickyContent.visible = false;
            newsContent.visible = false;
            appliancesContent.visible = false;
            recipesContent.visible = false;
            calendarContent.visible = false;
            clockContent.visible = false;
            musicContent.visible = false;
            weatherContent.visible = false;
            groceriesContent.visible = false;
            settingsContent.visible = false;
            helpContent.visible = false;
    
            object.visible = true;
        }
    }

    
    function updateColors() {
        favorites.updateColor();
        recipes.updateColor();
        appliances.updateColor();
        calendar.updateColor();
        social.updateColor();
        map.updateColor();
        music.updateColor();
        news.updateColor();
        weather.updateColor();
        games.updateColor();
        sticky.updateColor();
        groceries.updateColor();
        settings.updateColor();
    }
    
    Component.onCompleted: {
        unselectAllSideButtons();
        favorites.select();
    }

    SideButton {
        id: favorites
        text: "Clock"
        source: "images/clock_icon.png"
        selectColor: sidebtnmenu.selectColor
        unselectColor: sidebtnmenu.unselectColor
        onClicked: {
            if(userSelection.visible == false){
                unselectAllSideButtons();
                favorites.select();
                setVisible(clockContent);
            }
        }
    }
    SideButton {
        id: recipes
        text: "Recipes"
        source: "images/recipe_icon.png"
        selectColor: sidebtnmenu.selectColor
        unselectColor: sidebtnmenu.unselectColor
        onClicked: {
            if(userSelection.visible == false){
                unselectAllSideButtons();
                recipes.select();
                recipesContent.startUp();
                setVisible(recipesContent);
            }
        }
    }
    SideButton {
        id: appliances
        text: "Appliances"
        source: "images/appliance_icon.png"
        selectColor: sidebtnmenu.selectColor
        unselectColor: sidebtnmenu.unselectColor
        onClicked: {
            if(userSelection.visible == false){
                unselectAllSideButtons();
                appliances.select();
                appliancesContent.setTheme();
                appliancesContent.checkThemeStatus();
                setVisible(appliancesContent);
            }
        }
    }
    SideButton {
        id: calendar
        text: "Calendar"
        source: "images/calendar_icon.png"
        selectColor: sidebtnmenu.selectColor
        unselectColor: sidebtnmenu.unselectColor
        onClicked: {
            if(userSelection.visible == false){
                unselectAllSideButtons();
                calendar.select();
                setVisible(calendarContent);
            }
        }
    }
    SideButton {
        id: social
        text: "Social"
        source: "images/social_icon.png"
        selectColor: sidebtnmenu.selectColor
        unselectColor: sidebtnmenu.unselectColor
        onClicked: {
            if(userSelection.visible == false){
                unselectAllSideButtons();
                social.select();
                setVisible(socialContent);
            }
        }
    }
    SideButton {
        id: map
        text: "Map"
        source: "images/maps_icon.png"
        selectColor: sidebtnmenu.selectColor
        unselectColor: sidebtnmenu.unselectColor
        onClicked: {
            if(userSelection.visible == false){
                unselectAllSideButtons();
                map.select();
                setVisible(mapContent);
            }
        }
    }
    SideButton {
        id: music
        text: "Music"
        source: "images/music_icon.png"
        selectColor: sidebtnmenu.selectColor
        unselectColor: sidebtnmenu.unselectColor
        onClicked: {
            if(userSelection.visible == false){
                unselectAllSideButtons();
                music.select();
                setVisible(musicContent);
            }
        }
    }
    SideButton {
        id: news
        text: "News"
        source: "images/news_icon.png"
        selectColor: sidebtnmenu.selectColor
        unselectColor: sidebtnmenu.unselectColor
        onClicked: {
            if(userSelection.visible == false){
                unselectAllSideButtons();
                news.select();
                newsContent.startUp();
                setVisible(newsContent);
            }
        }
    }
    SideButton {
        id: weather
        text: "Weather"
        source: "images/weather_icon.png"
        selectColor: sidebtnmenu.selectColor
        unselectColor: sidebtnmenu.unselectColor
        onClicked: {
            if(userSelection.visible == false){
                unselectAllSideButtons();
                weather.select();
                setVisible(weatherContent);
            }
        }
    }
    SideButton {
        id: games
        text: "Games"
        source: "images/games_icon.png"
        selectColor: sidebtnmenu.selectColor
        unselectColor: sidebtnmenu.unselectColor
        onClicked: {
            if(userSelection.visible == false){
                unselectAllSideButtons();
                games.select();
                setVisible(gameContent);
            }
        }
    }
    SideButton {
        id: sticky
        text: "Sticky Notes"
        source: "images/sticky_icon.png"
        selectColor: sidebtnmenu.selectColor
        unselectColor: sidebtnmenu.unselectColor
        onClicked: {
            if(userSelection.visible == false){
                unselectAllSideButtons();
                sticky.select();
                setVisible(stickyContent);
            }
        }
    }
    SideButton {
        id: groceries
        text: "Grocery List"
        source: "images/grocery_icon.png"
        selectColor: sidebtnmenu.selectColor
        unselectColor: sidebtnmenu.unselectColor
        onClicked: {
            if(userSelection.visible == false){
                unselectAllSideButtons();
                groceries.select();
                setVisible(groceriesContent);
            }
        }
    }
    SideButton {
        id: settings
        text: "Settings"
        source: "images/settings_icon.png"
        selectColor: sidebtnmenu.selectColor
        unselectColor: sidebtnmenu.unselectColor
        onClicked: {
            if(userSelection.visible == false){
                unselectAllSideButtons();
                settings.select();
                settingsContent.reset();
                setVisible(settingsContent);
            }
        }
    }
}
